<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
		window.onload=function(){
			var btns = document.querySelectorAll('button');			
			for (var i = 0;i < btns.length;i++) {				 
				btns[i].index = i;
				btns[i].onclick = function() {
					this.remove();
					console.log(this.index)
				}
			}
		}			
		</script>
	</head>
	<body>
		<button>按钮1</button>
		<button>按钮2</button>
		<button>按钮3</button>
		<button>按钮4</button>
		<button>按钮5</button>
	</body>
</html>
